import java.util.Scanner;

public class y {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        if (str.length() < 3) {
            System.out.println(0);
            return;
        }
        int res = 0;
        for (int i = 0; i < str.length() - 2; i++) {
            int cnt = 0;
            int max = 0;
            int t1 = -1;
            int t2 = -1;
            for (int j = i, f = i + 2; j < str.length() - 2;) {
                if (str.charAt(j) == str.charAt(f)) {
                    cnt++;
                    max = Math.max(cnt, max);

                    t1 = Math.min(t1,j);
                    t2 = Math.max(t2,f);
                    if (f + 3 > str.length()) {
                        break;
                    } else {
                        f += 3;
                        j += 3;
                    }
                } else {
                    cnt = 0;
                    j++;
                    f++;
                }
            }
            if (max < str.length() / 3 && (t1 >= 3 || t2 <= str.length() - 4)) {
                max++;
            }
            res = Math.max(res, max);
        }
        if (res == 0) res++;
        System.out.println(res);
    }
}
